import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  OneToOne,
  JoinColumn,
  JoinTable,
  OneToMany,
  ManyToMany,
  BaseEntity,
  ManyToOne
} from 'typeorm';
import { LikeVideo } from '../likeVideo/likeVideo.entity';
import { WxUser } from '../wxUser/wxUser.entity';
import { InternetCelebrity } from '../internetCelebrity/internetCelebrity.entity';
import { ShieLD } from '../shield/shield.entity';
import { CheckTextEnum, EnumInIc, EnumIsHome, IsRewardEnum, OriginalEnum, OverseasEnum, ProfitTypeEnum, SourceEnum, VideoEnum } from './video.enum'
import { InternetCelebrityGroup } from '../internetCelebrityGroup/internetCelebrityGroup.entity';
import { VideoTag } from '../videoTag/videoTag.entity';
import { EnumRejectReasonType } from '../rejectReason/rejectReason.enum';

@Entity()
export class Video extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ name: 'title' })
  title: string;

  @Column({ name: 'desc' })
  desc: string;

  @Column({ name: 'ic_group' })
  ic_group: number;

  @Column({ name: 'video_url' })
  video_url: string;

  @Column({ name: 'video_url_source' })
  video_url_source: string;

  @Column({ name: 'video_cover' })
  video_cover: string;

  @Column({ name: 'video_id' })
  video_id: string;

  @PrimaryGeneratedColumn('uuid')
  @Column({ name: 'video_key' })
  video_key: string;

  @Column({ name: 'video_ratio' })
  video_ratio: string;

  @Column({ name: 'wx_user' })
  wx_user: string;

  @Column({ name: 'check' })
  check: number;

  @Column({ name: 'disabled' })
  disabled: number;

  @Column({ name: 'check_text' })
  check_text: CheckTextEnum;

  @Column({ name: 'check_text_time' })
  check_text_time: Date;

  @Column({ name: 'type' })
  type: VideoEnum; //0：视频 1：图片

  @Column({ name: 'source' })
  source: SourceEnum;

  @Column({ name: 'create_time' })
  create_time: Date;

  @Column({ name: 'update_time' })
  update_time: Date;

  @Column({ name: 'check_time' })
  check_time: Date;

  //是否是原创视频。0：非原创 1：原创 默认非原创
  @Column({ name: 'original' })
  original: OriginalEnum;

  //盈利方式。0：看答案 1：看作品
  @Column({ name: 'profit_type' })
  profit_type: ProfitTypeEnum;

  @Column({ name: 'trace_id' })
  trace_id: string;

  @Column({ name: 'isreward' })
  isreward: IsRewardEnum;

  @Column({ name: 'overseas' })
  overseas: OverseasEnum;

  @Column({ name: 'id_card' })
  id_card: string;
  
  @Column({ name: 'filemd5' })
  filemd5: string;

  @Column({ name: 'is_home' })
  is_home: EnumIsHome;

  @OneToMany(() => LikeVideo, (photo) => photo.video_)
  likes: LikeVideo[];

  @ManyToOne(() => WxUser, (autherinfo) => autherinfo.video_)
  @JoinColumn({name:'wx_user'})
  wx_user_info: WxUser[];

  @Column({ name: 'wx_user_source' })
  wx_user_source: string;

  @ManyToOne(() => InternetCelebrityGroup, (icInfo) => icInfo.video_)
  @JoinColumn({name:'ic_group'})
  ic_info: InternetCelebrityGroup;

  @OneToMany(() => ShieLD, (photo) => photo.video_)
  shield: ShieLD[];

  @OneToMany(() => VideoTag, (vt) => vt.video_)
  video_tag: VideoTag[];

  @Column({ name: 'delete_tag' })
  delete_tag: number;

  @Column({ name: 'in_ic' })
  in_ic: EnumInIc;

  @Column({ name: 'look_video_and_answer' })
  look_video_and_answer: number;

  @Column({ name: 'reject_reason' })
  reject_reason: string;

  @Column({ name: 'ic_group_source' })
  ic_group_source: number;

  @Column({ name: 'use_id'})
  use_id: number;

  @Column({ name: 'del_to_in_lib'})
  del_to_in_lib: number;

  @Column({ name: 'basic_questions' })
  basic_questions: number;

  @Column({ name: 'basic_reward' })
  basic_reward: number;

  @Column({ name: 'auto_online_time' })
  auto_online_time: Date;

  @Column({ name: 'auto_online' })
  auto_online: number;
}
